package com.qing.controller;

import com.qing.pojo.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

import com.qing.service.EmployeeDetailsService;
import com.qing.pojo.EmployeeDetails;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author qinghua
 * @since 2022-06-06
 */
@RestController
@RequestMapping("/employee-details")
public class EmployeeDetailsController {
    @Autowired
    private EmployeeDetailsService employeeDetailsService;

    @PostMapping("/insert")
    public EmployeeDetails save(@RequestBody EmployeeDetails employeeDetails) {
        employeeDetailsService.saveOrUpdate(employeeDetails);
        return employeeDetails;
    }

    @GetMapping("/deleteById/{id}")
    public Boolean delete(@PathVariable Integer id) {
        return employeeDetailsService.removeById(id);
    }

    @GetMapping("/queryAll")
    public List<EmployeeDetails> queryAll() {
        return employeeDetailsService.list();
    }

    @GetMapping("/queryById/{id}")
    public EmployeeDetails findOne(@PathVariable Integer id) {
        return employeeDetailsService.getById(id);
    }

}

